/*
  Copyright © 2010  Rodrigo Peixoto

      This file is part of Touché.

      Touché is free software: you can redistribute it and/or modify
      it under the terms of the GNU Lesser General Public License as published
      by the Free Software Foundation, either version 3 of the License, or
      (at your option) any later version.

      This program is distributed in the hope that it will be useful,
      but WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      GNU Lesser General Public License for more details.

      You should have received a copy of the GNU Lesser General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#include "channel.h"

Channel::Channel(QString name, QString password):m_name(name), m_password(password)
{
}
Channel::Channel(QPair<QString, QString>nameAndPassword): m_name(nameAndPassword.first), m_password(nameAndPassword.second)
{
}

QString Channel::name()
{
    return this->m_name;
}

void Channel::setName(QString name)
{
    this->m_name = name;
}

QString Channel::password()
{
    return this->m_password;
}

void Channel::setPassword(QString password)
{
    this->m_password = password;
}

void Channel::addUser(QString userBarejid)
{
    if(!this->m_usersBarejid.contains(userBarejid)){
        this->m_usersBarejid << userBarejid;
    }
}
void Channel::removeUser(QString bareJid)
{
    if(this->hasUser(bareJid)){
        this->m_usersBarejid.removeAt(this->m_usersBarejid.indexOf(bareJid));
    }
}

QStringList Channel::usersBarejid()
{
    return this->m_usersBarejid;
}

bool Channel::hasUser(QString bareJid)
{
    return this->m_usersBarejid.contains(bareJid);
}

bool Channel::isEmpty()
{
    return this->m_usersBarejid.size() <= 0;
}
